package com.usian.common.interceptor;

import com.usian.utils.threadlocal.UserIdThreadLocalUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ArticleInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        String userId = request.getHeader("userId");
        if (userId!=null) {
            UserIdThreadLocalUtils.setUserId(Integer.valueOf(userId));
            return true;
        }else {
            return false;
        }

    }


}
